#include<iostream>
using namespace std;
const int M = 1000010, N = 100010;
char s[M], p[N];
int ne[N];

int main() {
	int n, m;
	cin >> n >> p >> m >> s;
	memset(ne, -1, sizeof ne);

	for (int i = 1, j = -1; i < n; i++) {
		while (j != -1 && p[i] != p[j + 1]) j = ne[j];
		if (p[i] == p[j + 1])  j++;
		ne[i] = j;
	}

	for (int i = 0, j = -1; i < m; i++) {
		while (j != -1 && s[i] != p[j + !]) j = ne[j];
		if (s[i] == p[j + 1])  j++;
		if (j == n - 1) {
			printf("%d ", i - n + 1);
			j = ne[j];
		}
	}
	return 0;
}